home *** CD-ROM | disk | FTP | other *** search
- /* スプライトプロセッサ用ルーチン */
-
-
- /* PATファイルのヘッダ */
- typedef struct
- {
- int a; /* 意味無し */
- char name[41]; /* 名前 */
- char subname[15];
- int xlen,ylen,bufx,bufy,patbufsize,res1;
- char selected,nodisp;
- int res2,res3;
- char res4[34];
- } P_HEAD;
-
-
- typedef struct
- {
- short patnum; /* キャラクタの数 */
- short palnum; /* パレットの数 */
- short sprnum; /* スプライトパターンの数 */
- } S_HEAD;
-
-
- typedef struct
- {
- short topnum; /* 先頭パターン番号 */
- short xlen; /* 横方向パターン数 */
- short ylen; /* 縦方向パターン数 */
- short col; /* 色テーブル番号として設定する値 */
- } CHRDAT;
-
-
- /* パターンデータ格納用構造体 */
- typedef struct
- {
- char *header; /* ARTemis用のヘッダ */
- int patx,paty; /* 16ドット単位でのサイズ */
- char *patbuf; /* パターン格納領域(16) */
- short *p32buf; /* パターン格納領域(32K) */
- int palnum; /* 参照するパレットの番号(-1で32K色) */
- } PATTERN;
-
-
-
-
- /* グローバル変数 */
- char path[64]=""; /* 現在のパス */
- unsigned int drv=0; /* 現在のドライブ */
- char workfn[100]; /* 作業中ファイルのフルパス */
- PATTERN pter[1024]; /* パターンデータ格納用 */
- int PALNUM=0,PATNUM=0; /* メモリ上に有るパレット,パターンの総数 */
- int SPRNUM=0; /* メモリ上に有るスプライトの総数 */
- short PAL_USE[1024]; /* そのパレットが幾つのパターンに使用されてるか */
- short PAL[1024][16]; /* パレットデータ */
- short stkpal=-1; /* スタック内のパレットデータ */
-
- char *fileSelBuf; /* ファイルセレクタ描画用バッファ */
- char *zoomDlgBuf; /* 拡大ビュアー描画用バッファ */
- short *magBuf; /* 拡大後のパターン保持用バッファ */
- char saveBuf[512]; /* セーバー用ワーク */
- char *sureBuf; /* SPM_sureのダイアログ描画用バッファ */
- char *errMesBuf; /* SPM_errMesの描画用バッファ */
- char *frameBuf; /* 再描画用のバッファ */
-
- /* About... */
- void SPM_about()
- {
- int x,y,b,xd,yd;
- char *buf;
- if ( (buf=YGU_pushScreenBlock(gwork,156,190,200,100))==NULL)
- return;
- /* 気合を込めて!(^^;) */
- MOS_disp(0);
- MOS_rdpos(&b,&x,&y);
- MOS_horizon(156,355);
- MOS_vertical(190,289);
- YGB_writeMode(gwork,PSET);
- SGB_gradProButton(gwork,156,190,355,289,_C(27,27,18),_C(9,9,6),0);
- YGB_fontSize(gwork,8,16);
- YGB_color(gwork,_C(9,4,0));
- YGB_print(gwork,192,220,"SPrite Processor");
- YGB_print(gwork,193,220,"SPrite Processor");
- YGB_color(gwork,_C(11,5,2));
- YGB_fontSize(gwork,8,12);
- YGB_print(gwork,224,240,"Ver1.00");
- YGB_print(gwork,225,240,"Ver1.00");
-
- YGB_color(gwork,_C(0,0,0));
- YGB_fontSize(gwork,6,12);
- YGB_print(gwork,208,276,"MXMIV (C)SANDMAN");
- YGB_print(gwork,263,276,"SANDMAN");
- b=0;
- MOS_setpos(256,240);
- MOS_disp(1);
- while (b==0)
- MOS_rdpos(&b,&xd,&yd);
- YGU_popScreenBlock(gwork,buf);
- MOS_horizon(0,505);
- MOS_vertical(0,473);
- MOS_setpos(x,y);
- return;
- }
-
-
- /* エラーメッセージの表示 */
- void SPM_errMes(char *str)
- {
- int x,y,dmy,b=0,lx;
- char *buf;
- unsigned int len;
-
- len=strlen(str);
- lx=len*6+4;
-
- if (len>80)
- { SPM_errMes("阿呆! > 自分"); return; }
-
- MOS_rdpos(&b,&x,&y);
- MOS_disp(0);
- YGB_getPattern(gwork,errMesBuf,x-lx/2,y-8,x+lx/2,y+7);
- YGB_writeMode(gwork,PSET);
- SGB_gradStrProButton(gwork,x-lx/2,y-8,_C(18,25,18),_C(8,8,8),0,str,
- 6,12,0,_C(31,31,31));
- MOS_disp(1);
- while (b==0)
- MOS_rdpos(&b,&dmy,&dmy);
- MOS_disp(0);
- YGB_putPattern(gwork,errMesBuf,x-lx/2,y-8,x+lx/2,y+7);
- MOS_disp(1);
- return;
- }
-
-
-
-
- /* YES? NO? ...def=0 で YES/NO, def=2で確認 , def=9999 でパレット*/
- int SPM_sure(char *mes,int def)
- {
- int x0,y0;
- int a,x,y,len,sx,sy,val;
- ITEM *itms[2],*act;
- char *pushBuf,*tok,*sp;
- char str[500];
-
- sp=str;
-
- strcpy(str,mes);
-
- MOS_disp(0);
- YGB_writeMode(gwork,PSET);
- MOS_rdpos(&a,&x,&y);
- x0=x-124;
- x0= (x0<0) ? 0 : x0;
- x0= (x0>264) ? 264 : x0;
- y0=y-60;
- y0= (y0<0) ? 0 : y0;
- y0= (y0>359) ? 359 : y0;
-
- MOS_disp(0);
- YGB_getPattern(gwork,sureBuf,x0,y0,x0+247,y0+120);
-
- /* ダイアログベース */
- SGB_proButton(gwork,x0,y0,x0+247,y0+120, _C(4,4,4));
-
- /* タイトルバー */
- SGB_gradProButton(gwork,x0,y0,x0+247,y0+60,_C(27,27,18),_C(9,9,6),0);
- /* 表示領域 */
- SGB_holButton(gwork,x0+12,y0+12,x0+235,y0+79, _C(3,3,3));
-
- /* 文字列の描画 */
- YGB_fontSize(gwork,6,12);
- YGB_color(gwork,_C(24,24,27));
- sy=y0+28;
- sp=strtok(sp,"@@");
- len=strlen(sp); sx=x0+124-len*3;
- YGB_print(gwork,sx,sy,sp);
-
- while(1)
- {
- sy+=12;
- sp=strtok(NULL,"@@");
- if (sp==NULL)
- break;
- len=strlen(sp); sx=x0+124-len*3;
- YGB_print(gwork,sx,sy,sp);
- }
-
- /* パレットバッファの内容表示 */
- if (def==9999 && stkpal!=-1)
- {
- YGB_writeMode(gwork,OPAQUE);
- YGB_color(gwork,_C(24,24,24));
- YGB_boxFul(gwork,x0+59,y0+71,x0+187,y0+78);
- for (x=0;x<16;x++)
- {
- YGB_color(gwork,PAL[stkpal][x]);
- YGB_boxFul(gwork,x0+60+x*8,y0+72,x0+66+x*8,y0+78);
- }
- YGB_writeMode(gwork,PSET);
- def=0;
- }
-
-
- if (def!=2)
- {
- /* YES */
- SGB_proButton(gwork,x0+32,y0+91,x0+86,y0+110, _C(6,6,6));
- YGB_color(gwork,_C(23,23,23));
- YGB_fontSize(gwork,8,16);
- YGB_print(gwork,x0+47,y0+109,"YES");
- YGB_print(gwork,x0+48,y0+109,"YES");
- itms[0]=YGU_addButton(NULL,x0+32,y0+91,55,20);
- /* NO */
- SGB_proButton(gwork,x0+164,y0+91,x0+218,y0+110, _C(6,6,6));
- YGB_color(gwork,_C(20,20,20));
- YGB_fontSize(gwork,8,16);
- YGB_print(gwork,x0+183,y0+109,"NO");
- YGB_print(gwork,x0+184,y0+109,"NO");
- itms[1]=YGU_addButton(itms[0],x0+164,y0+91,55,20);
- }
- else
- {
- /* OK */
- SGB_proButton(gwork,x0+98,y0+91,x0+152,y0+110, _C(6,6,6));
- YGB_color(gwork,_C(23,23,23));
- YGB_fontSize(gwork,8,16);
- YGB_print(gwork,x0+119,y0+109,"OK");
- YGB_print(gwork,x0+120,y0+109,"OK");
- itms[0]=YGU_addButton(NULL,x0+98,y0+91,55,20);
- /* ダミー(クリック出来ない) */
- itms[1]=YGU_addButton(itms[0],511,479,1,1);
- }
-
- MOS_disp(1);
- while(1)
- {
- act=YGU_allItemsAction(gwork,itms[0]);
- if (act==itms[0])
- { val=1; break; }
- if (act==itms[1])
- { val=0; break; }
- MOS_rdpos(&a,&x,&y);
- if (a==2)
- { val=def; break; }
- }
-
- MOS_disp(0);
- YGB_putPattern(gwork,sureBuf,x0,y0,x0+247,y0+120);
- MOS_disp(1);
- YGU_deleteAll(itms[0]);
- return(val);
- }
-
-
-
-
- /* 現在の左上パターン番号とかを表示する */
- void SPM_printNumber(num)
- {
- char str[40];
- int ppal=0,i;
-
- SPRNUM=0;
- if (PAL_USE[stkpal]==1)
- ppal=1;
- for (i=0;i<PATNUM;i++)
- SPRNUM+=((pter[i].patx*pter[i].paty)*((pter[i].palnum==-1) ? 4 : 1));
-
- YGB_fontSize(gwork,6,12);
- YGB_color(gwork,_C(27,27,27));
- YGB_writeMode(gwork,OPAQUE);
- sprintf(str,"%04d/%04d SPR:%04d PAL:%04d",num,PATNUM,SPRNUM,PALNUM-ppal);
- YGB_print(gwork,print_x+26,print_y+13,str);
- return;
- }
-
-
-
-
- /* ものぐさファイルセレクト関数 */
- void SPM_fileSelect(char *msg,char *fn,char *wild)
- {
- int x,y,b,ret;
- char *buf;
-
- MOS_rdpos(&b,&x,&y);
- x = (x<60) ? 0 : x-60;
- y = (y<144) ? 20 : y-124;
-
- MOS_disp(0);
- YGB_getPattern(gwork,fileSelBuf,x,y,x+119,y+247);
- MOS_disp(1);
-
- ret=YGU_fileSelect(gwork,msg,&drv,path,fn,wild,x,y,120,248,6,12);
-
- if (ret==0)
- fn[0]=0;
- MOS_disp(0);
- YGB_putPattern(gwork,fileSelBuf,x,y,x+119,y+247);
- MOS_disp(1);
- YGB_writeMode(gwork,PSET);
- return;
- }
-
-
- /* 最適化済16色データを32K色モードに戻す */
- void SPM_expand(int ref,int lx,int ly,short *pal,short *tmpbuf)
- {
- int xlen,ylen,loop_x,loop_y,i,j;
- short upper,lower;
-
- /* calloc な感じにする */
- _fill_char(tmpbuf,lx*ly*2,0);
-
- ylen=pter[ref].paty << 4;
- xlen=pter[ref].patx << 4;
- loop_y=(ylen<ly) ? ylen : ly;
- loop_x=(xlen<lx) ? xlen : lx;
-
- if (pter[ref].palnum!=-1)
- {
- for (i=0;i<loop_y;i++)
- {
- for (j=0;j<loop_x/2;j++)
- {
- /* 16ビットデータに直す */
- /* 上下4ビットに分ける */
- upper=pter[ref].patbuf[(i*xlen>>1)+j];
- lower=upper & 15; upper=upper >> 4;
- upper=PAL[pter[ref].palnum][upper];
- lower=PAL[pter[ref].palnum][lower];
- tmpbuf[i*lx+(j<<1)]= upper;
- tmpbuf[i*lx+(j<<1)+1]=lower;
- }
- }
- }
- else
- {
- for (i=0;i<loop_y;i++)
- _move(&pter[ref].p32buf[i*xlen],&tmpbuf[i*lx],loop_x*2);
- }
- return;
- }
-
-
-
- /* 加工中のパターンデータを表示枠に転送 */
- void SPM_showWindow(int patnum)
- {
- int x,y,sx,sy,i,j;
- int xlen,ylen,loop_x,loop_y;
- short upper,lower;
- short *tmpbuf;
- int ref;
-
- MOS_disp(0);
-
- if ((tmpbuf=malloc(8192))==NULL)
- { SPM_errMes("メモリが足りません"); return; }
-
- YGB_writeMode(gwork,OPAQUE);
-
- for (y=0;y<4;y++)
- {
- for (x=0;x<6;x++)
- {
- /* 座標を定める */
- sx= x * sprWinStep_x + sprWin_x + 6;
- sy= y * sprWinStep_y + sprWin_y + 6;
-
- /* 要求されたパターン番号が大きいときはHolButton */
- if (PATNUM <= y*6+x+patnum)
- {
- SGB_holButton(gwork,sx,sy,sx+63,sy+63, _C(0,0,0));
- YGB_color(gwork,0);
- YGB_boxFul(gwork,sx-4,sy+74,sx+66,sy+90);
- continue;
- }
-
- /* そうでないならパターンを枠内に転送 */
- ref=y*6+x+patnum;
- SPM_expand(ref,64,64,PAL[pter[ref].palnum],tmpbuf);
- YGB_putPattern(gwork,(char*)tmpbuf,sx,sy,sx+63,sy+63);
-
- /* 次にパレット */
- if (pter[ref].palnum!=-1)
- {
- YGB_color(gwork,0);
- YGB_boxFul(gwork,sx-4,sy+74,sx+66,sy+90);
- for (i=0;i<2;i++)
- {
- for (j=0;j<8;j++)
- {
- YGB_color(gwork,PAL[pter[ref].palnum][(i<<3) +j]);
- YGB_boxFul(gwork,sx-4+j*9,sy+74+i*9,
- sx+3+j*9,sy+81+i*9);
- }
- }
- }
- else
- {
- YGB_color(gwork,0);
- YGB_boxFul(gwork,sx-4,sy+74,sx+66,sy+90);
- YGB_color(gwork,_C(24,24,24));
- YGB_fontSize(gwork,6,12);
- YGB_print(gwork,sx,sy+88,"32K data");
- }
- }
- }
- MOS_disp(1);
- YGB_writeMode(gwork,PSET);
- free(tmpbuf);
- return;
- }
-
-
-
-
- void SPM_showOne(int ref)
- {
- int x,y,sx,sy,i,j;
- int xlen,ylen;
- short *tmpbuf;
-
- if ( (ref<WINTOP*6) || ((ref-WINTOP*6)>=24) )
- return;
-
- MOS_disp(0);
-
-
- YGB_writeMode(gwork,OPAQUE);
-
- y=(ref-WINTOP*6)/6;
- x=(ref-WINTOP*6)%6;
-
- /* 座標を定める */
- sx= x * sprWinStep_x + sprWin_x + 6;
- sy= y * sprWinStep_y + sprWin_y + 6;
-
- /* 要求されたパターン番号が大きいときはHolButton */
- if (PATNUM <= ref)
- {
- SGB_holButton(gwork,sx,sy,sx+63,sy+63, _C(0,0,0));
- YGB_color(gwork,0);
- YGB_boxFul(gwork,sx-4,sy+74,sx+66,sy+90);
- MOS_disp(1);
- YGB_writeMode(gwork,PSET);
- return;
- }
-
- /* そうでないならパターンを枠内に転送 */
- if ((tmpbuf=malloc(8192))==NULL)
- { SPM_errMes("メモリが足りません"); return; }
- SPM_expand(ref,64,64,PAL[pter[ref].palnum],tmpbuf);
- YGB_putPattern(gwork,(char*)tmpbuf,sx,sy,sx+63,sy+63);
-
- /* 次にパレット */
- if (pter[ref].palnum!=-1)
- {
- YGB_color(gwork,0);
- YGB_boxFul(gwork,sx-4,sy+74,sx+66,sy+90);
- for (i=0;i<2;i++)
- {
- for (j=0;j<8;j++)
- {
- YGB_color(gwork,PAL[pter[ref].palnum][(i<<3) +j]);
- YGB_boxFul(gwork,sx-4+j*9,sy+74+i*9,
- sx+3+j*9,sy+81+i*9);
- }
- }
- }
- else
- {
- YGB_color(gwork,0);
- YGB_boxFul(gwork,sx-4,sy+74,sx+66,sy+90);
- YGB_color(gwork,_C(24,24,24));
- YGB_fontSize(gwork,6,12);
- YGB_print(gwork,sx,sy+88,"32K data");
- }
-
- MOS_disp(1);
- YGB_writeMode(gwork,PSET);
- free(tmpbuf);
- return;
- }
-
-
-
- void SPM_scrollShowWindow(int diff)
- {
- short *copybuf;
- int x,y,sx,sy,dx,dy,num,ref;
- int kaishi,keizoku,jikko; /* ひどい名前(^^;) */
- int plus;
-
- WINTOP+=diff;
-
- MOS_disp(0);
- YGB_writeMode(gwork,OPAQUE);
-
- /* まず、コピーから */
-
- kaishi= (diff<0) ? diff+3 : diff;
- keizoku=(diff<0) ? -1 : 4;
- jikko= (diff<0) ? -1 : 1;
-
- for (y=kaishi;y!=keizoku;y+=jikko)
- {
- for (x=0;x<6;x++)
- {
- sx= x * sprWinStep_x + sprWin_x + 6;
- sy= y * sprWinStep_y + sprWin_y + 6;
- dx= sx;
- dy= (y-diff) * sprWinStep_y + sprWin_y + 6;
-
-
- if ((copybuf=malloc(8192))==NULL)
- { SPM_errMes("メモリが足りません"); return; }
- YGB_getPattern(gwork,(char*)copybuf,sx,sy,sx+63,sy+63);
- YGB_putPattern(gwork,(char*)copybuf,dx,dy,sx+63,dy+63);
- free(copybuf);
- copybuf=malloc(71*17*2);
- YGB_getPattern(gwork,(char*)copybuf,sx-4,sy+74,sx+66,sy+90);
- YGB_putPattern(gwork,(char*)copybuf,dx-4,dy+74,dx+66,dy+90);
- free(copybuf);
- }
- }
-
-
- num=WINTOP*6;
- /* 次は新しく描く */
- if (diff>0)
- {
- for (y=4-diff;y<=3;y++)
- {
- for (x=0;x<6;x++)
- {
- ref=(WINTOP+y)*6+x;
- SPM_showOne(ref);
- }
- }
- }
- else
- {
- for (y=0;y<_abs(diff);y++)
- {
- for (x=0;x<6;x++)
- {
- ref=(WINTOP+y)*6+x;
- SPM_showOne(ref);
- }
- }
- }
-
- MOS_disp(1);
- return;
- }
-
-
- /* ファイルメニュー
-
- /* PATファイル新規読み込み */
- void SPM_readNewPAT()
- {
- P_HEAD header;
- char *pat; /* 最適化後のパターン格納領域 */
- short pal[16]; /* パレットデータ格納領域 */
- short *patbuf; /* パターンデータ格納用 */
- short *tmpbuf; /* ファイルから読んだ直後のパターン */
- char fn[13]; /* ファイルネーム */
- int xlen,ylen; /* パターンのサイズ */
- int patx,paty; /* 16ドット単位のパターンの数 */
- int dotnum; /* ドットの数 */
- int i,j,ret,pt=0;
-
-
- fn[0]=0;
- SPM_fileSelect("ARTemisロード",fn,"");
- if (fn[0]==0)
- return;
-
- YSC_makeFullPath(workfn,drv,path,fn);
-
- if ( (fp=fopen(workfn,"rb"))==NULL)
- { SPM_errMes("ファイルエラー!"); return; }
-
- /* いままで保持していたデータ領域の開放 */
- for (i=0;i<PATNUM;i++)
- {
- free(pter[i].patbuf);
- free(pter[i].p32buf);
- if (pter[i].header!=NULL)
- free(pter[i].header);
- }
- PATNUM=0; PALNUM=0; SPRNUM=0; stkpal=-1;
-
- fread(&header,sizeof(P_HEAD),1,fp);
- while (!feof(fp))
- {
- /* 読み取り用ポインタ初期化 */
- pt=0;
- /* まずヘッダの解析から */
- /* パターンのサイズを計算 */
- xlen=header.xlen; ylen=header.ylen;
- patx=(xlen+15)>>4; paty=(ylen+15)>>4;
- dotnum=patx*paty<<8;
-
- /* パターンデータをメモリに格納 */
- if ( (patbuf=calloc(dotnum*2,1))==NULL)
- { SPM_errMes("メモリが足りません"); return; }
- if ( (tmpbuf=malloc(header.patbufsize))==NULL)
- { SPM_errMes("メモリが足りません"); return; }
-
- fread(tmpbuf,header.patbufsize,1,fp);
-
- /* デバッグ */
- //YGB_putPattern(gwork,(char*)tmpbuf,0,0,239,199);
-
-
- for (i=0;i<ylen;i++)
- {
- for (j=0;j<xlen;j++)
- { patbuf[(i*patx<<4)+j]=tmpbuf[pt]; pt++; }
- }
- free(tmpbuf);
-
- /* 構造体の中に入れておく。 */
- pter[PATNUM].patx=patx;
- pter[PATNUM].paty=paty;
- pter[PATNUM].header=malloc(128);
- _move(&header,pter[PATNUM].header,128);
- pter[PATNUM].p32buf=patbuf;
- if ((pter[PATNUM].patbuf=malloc(dotnum/2))==NULL)
- { SPM_errMes("メモリ不足です"); fclose(fp); return; }
- pter[PATNUM].palnum=-1;
-
- /* デバッグ2 */
- //printf ("No.%03d patx=%02d paty=%02d",PALNUM,patx,paty);
-
- /* 変数をセット */
- PATNUM++;
- SPRNUM+=(patx*paty)*4;
-
- fread(&header,sizeof(P_HEAD),1,fp);
- }
-
- /* スクロールバーを書き換え */
- YGU_resetScrollBar(gwork,itm[29],(PATNUM+5)/6,4);
- WINTOP=0;
- YGB_writeMode(gwork,PSET);
-
- SPM_showWindow(0);
- SPM_printNumber(0);
-
- /* パレットの使用状態フラグをクリア */
- _fill_char(PAL_USE,2048,0);
-
- fclose(fp);
- return;
- }
-
-
-
-
- /* PATファイル追加読み込み */
- void SPM_addPAT()
- {
- P_HEAD header;
- char *pat; /* 最適化後のパターン格納領域 */
- short pal[16]; /* パレットデータ格納領域 */
- short *patbuf; /* パターンデータ格納用 */
- short *tmpbuf; /* ファイルから読んだ直後のパターン */
- char fn[13]; /* ファイルネーム */
- int xlen,ylen; /* パターンのサイズ */
- int patx,paty; /* 16ドット単位のパターンの数 */
- int dotnum; /* ドットの数 */
- int i,j,ret,pt=0;
-
-
- fn[0]=0;
- SPM_fileSelect("ARTemisロード",fn,"");
- if (fn[0]==0)
- return;
-
- YSC_makeFullPath(workfn,drv,path,fn);
-
- if ( (fp=fopen(workfn,"rb"))==NULL)
- { SPM_errMes("ファイルエラー!"); return; }
-
-
- fread(&header,sizeof(P_HEAD),1,fp);
- while (!feof(fp))
- {
- /* 読み取り用ポインタ初期化 */
- pt=0;
- /* まずヘッダの解析から */
- /* パターンのサイズを計算 */
- xlen=header.xlen; ylen=header.ylen;
- patx=(xlen+15)>>4; paty=(ylen+15)>>4;
- dotnum=patx*paty<<8;
-
- /* パターンデータをメモリに格納 */
- if ( (patbuf=calloc(dotnum*2,1))==NULL)
- { SPM_errMes("メモリが足りません"); return; }
- if ( (tmpbuf=malloc(header.patbufsize))==NULL)
- { SPM_errMes("メモリが足りません"); return; }
-
- fread(tmpbuf,header.patbufsize,1,fp);
-
- /* デバッグ */
- //YGB_putPattern(gwork,(char*)tmpbuf,0,0,239,199);
-
-
- for (i=0;i<ylen;i++)
- {
- /* 補正した時のずれは0で埋める(callocだから不要) */
- for (j=0;j<xlen;j++)
- { patbuf[(i*patx<<4)+j]=tmpbuf[pt]; pt++; }
- }
- free(tmpbuf);
-
- /* 構造体の中に入れておく。 */
- if ((pter[PATNUM].header=malloc(sizeof(P_HEAD)))==NULL)
- { SPM_errMes("メモリが足りません"); return; }
- _move(&header,pter[PATNUM].header,sizeof(P_HEAD));
- pter[PATNUM].patx=patx;
- pter[PATNUM].paty=paty;
- pter[PATNUM].p32buf=patbuf;
- if ((pter[PATNUM].patbuf=malloc(dotnum/2))==NULL)
- { SPM_errMes("メモリ不足です"); fclose(fp); return; }
- pter[PATNUM].palnum=-1;
-
- /* デバッグ2 */
- //printf ("No.%03d patx=%02d paty=%02d",PALNUM,patx,paty);
-
- /* 変数をセット */
- PATNUM++;
- SPRNUM+=(patx*paty);
-
- fread(&header,sizeof(P_HEAD),1,fp);
- }
-
- /* スクロールバーを書き換え */
- YGU_resetScrollBar(gwork,itm[29],(PATNUM+5)/6,4);
- YGU_setScrollBarPointer(gwork,itm[29],WINTOP);
- YGB_writeMode(gwork,PSET);
-
- SPM_showWindow(WINTOP*6);
- SPM_printNumber(WINTOP*6);
-
- fclose(fp);
- return;
- }
-
-
-
- /* SPP形式でセーブ */
- void SPM_saveSPP()
- {
- S_HEAD hd;
- CHRDAT chd;
- char fn[13]; /* ファイルネーム */
- int dotnum,lx,ly;
- int i,j,ret,p=0,pn,x,y;
-
- fn[0]=0;
- SPM_fileSelect("SPPセーブ",fn,"SPP");
- if (fn[0]==0)
- return;
- YSC_changeExt(fn,"SPP");
-
- YSC_makeFullPath(workfn,drv,path,fn);
-
- if ( (fp=fopen(workfn,"rb"))!=NULL)
- {
- if (SPM_sure(" @@ 上書きします @@ いいですか? ",0)==0)
- return;
- }
- fclose(fp);
- if ((fp=fopen(workfn,"wb"))==NULL)
- { SPM_errMes("ファイルエラー!"); return; }
-
- SPM_arrangePALnumber();
- SPM_printNumber(WINTOP*6);
-
- hd.patnum=PATNUM; hd.palnum=PALNUM; hd.sprnum=SPRNUM;
-
- if (fwrite(&hd,sizeof(S_HEAD),1,fp)!=1)
- { SPM_errMes("ディスク容量が無いのでは?"); fclose(fp); return; }
-
- for (i=0;i<PATNUM;i++)
- {
- chd.topnum=p;
- p+= (pter[i].patx*pter[i].paty) * ((pter[i].palnum==-1) ? 4 : 1);
- chd.xlen=pter[i].patx; chd.ylen=pter[i].paty;
- chd.col=(pter[i].palnum==-1) ? 0 : (pter[i].palnum+32768+256);
- if (fwrite(&chd,sizeof(CHRDAT),1,fp)!=1)
- { SPM_errMes("ディスク容量が無いのでは?"); fclose(fp); return; }
-
- }
-
- for (i=0;i<PALNUM;i++)
- {
- if (fwrite(PAL[i],32,1,fp)!=1)
- { SPM_errMes("ディスク容量が無いのでは?"); fclose(fp); return; }
- }
-
- for (i=0;i<PATNUM;i++)
- {
- /* 32K */
- if (pter[i].palnum==-1)
- {
- lx=pter[i].patx; ly=pter[i].paty;
- for (y=0;y<ly;y++)
- {
- for (x=0;x<lx;x++)
- {
- for (j=0;j<16;j++)
- {
- _move(&pter[i].p32buf[(y*lx<<8)+(x<<4)+(j*lx<<4)],
- &saveBuf[j<<5],32);
- }
- fwrite(saveBuf,512,1,fp);
- }
- }
- }
- else /* 16 */
- {
- lx=pter[i].patx; ly=pter[i].paty;
- for (y=0;y<ly;y++)
- {
- for (x=0;x<lx;x++)
- {
- for (j=0;j<16;j++)
- {
- _move(&pter[i].patbuf[(y*lx<<7)+(x<<3)+(j*lx<<3)],
- &saveBuf[j<<3],8);
- }
- if (fwrite(saveBuf,128,1,fp)!=1)
- {
- SPM_errMes("ディスク容量が無いのでは?");
- fclose(fp);
- return;
- }
- }
- }
- }
- }
- fclose(fp);
- return;
- }
-
-
- /* SPP新規読み込み */
- void SPM_readNewSPP()
- {
- S_HEAD hd;
- CHRDAT chd;
- char fn[13]; /* ファイルネーム */
- char *tmpbuf;
- int dotnum,lx,ly;
- int i,j,ret,p=0,pn,x,y;
-
- fn[0]=0;
- SPM_fileSelect("SPP新規読み込み",fn,"SPP");
- if (fn[0]==0)
- return;
- YSC_changeExt(fn,"SPP");
-
- YSC_makeFullPath(workfn,drv,path,fn);
-
- if ((fp=fopen(workfn,"rb"))==NULL)
- { SPM_errMes("ファイルエラー!"); return; }
-
-
- /* いままで保持していたデータ領域の開放 */
- for (i=0;i<PATNUM;i++)
- {
- free(pter[i].patbuf);
- free(pter[i].p32buf);
- if (pter[i].header!=NULL)
- free(pter[i].header);
- }
-
-
- fread(&hd,6,1,fp);
-
- PATNUM=hd.patnum; PALNUM=hd.palnum; SPRNUM=hd.sprnum; stkpal=-1;
- _fill_char(PAL_USE,2048,0);
-
- for (i=0;i<PATNUM;i++)
- {
- fread(&chd,8,1,fp);
- if ((pter[i].p32buf=(short*)malloc((chd.xlen*chd.ylen)<<9))==NULL)
- { SPM_errMes("メモリ不足です");fclose(fp);return; }
-
- if ((pter[i].patbuf=(char*)malloc((chd.xlen*chd.ylen)<<7))==NULL)
- { SPM_errMes("メモリ不足です");fclose(fp);return; }
- pter[i].header=NULL;
- pter[i].patx=chd.xlen; pter[i].paty=chd.ylen;
- pter[i].palnum=chd.col;
- if (pter[i].palnum==0)
- pter[i].palnum--;
- else
- pter[i].palnum=(pter[i].palnum & 32767)-256;
- }
-
- for (i=0;i<PALNUM;i++)
- fread(PAL[i],32,1,fp);
-
- if ((tmpbuf=(char*)malloc(512))==NULL)
- { SPM_errMes("メモリ不足です");fclose(fp);return; }
-
- for (i=0;i<PATNUM;i++)
- {
- lx=pter[i].patx; ly=pter[i].paty;
- /* 32K */
- if (pter[i].palnum==-1)
- {
- for (y=0;y<ly;y++)
- {
- for(x=0;x<lx;x++)
- {
- fread(tmpbuf,1,512,fp);
- for (j=0;j<16;j++)
- {
- _move(&(tmpbuf[j<<5]),
- &(pter[i].p32buf[(y*lx<<8)+(x<<4)+(j*lx<<4)]),32);
- }
- }
- }
- }
- else /* 16 */
- {
- for (y=0;y<ly;y++)
- {
- for(x=0;x<lx;x++)
- {
- fread(tmpbuf,128,1,fp);
- for (j=0;j<16;j++)
- {
- _move(&tmpbuf[j<<3],
- (&pter[i].patbuf[(y*lx<<7)+(x<<3)+(j*lx<<3)]),8);
- }
- }
- }
- SPM_expand(i,pter[i].patx*16,pter[i].paty*16,
- PAL[pter[i].palnum],pter[i].p32buf);
- PAL_USE[pter[i].palnum]++;
- }
- }
- fclose(fp);
- YGU_resetScrollBar(gwork,itm[29],(PATNUM+5)/6,4);
- YGB_writeMode(gwork,PSET);
- WINTOP=0;
- SPM_showWindow(0);
- SPM_printNumber(0);
- free(tmpbuf);
- return;
- }
-
-
-
- /* SPM追加 */
- void SPM_addSPP()
- {
- S_HEAD hd;
- CHRDAT chd;
- char fn[13]; /* ファイルネーム */
- char *tmpbuf;
- int dotnum,lx,ly;
- int i,j,ret,p=0,pn,x,y;
-
- fn[0]=0;
- SPM_fileSelect("SPP新規読み込み",fn,"SPP");
- if (fn[0]==0)
- return;
- YSC_changeExt(fn,"SPP");
-
- YSC_makeFullPath(workfn,drv,path,fn);
-
- if ((fp=fopen(workfn,"rb"))==NULL)
- { SPM_errMes("ファイルエラー!"); return; }
-
- /* 最初にバッファを確保 */
- if ((tmpbuf=(char*)malloc(512))==NULL)
- { SPM_errMes("メモリ不足です");fclose(fp);return; }
-
- fread(&hd,6,1,fp);
-
- SPM_arrangePALnumber();
-
- for (i=PATNUM;i<PALNUM+hd.patnum;i++)
- {
- fread(&chd,8,1,fp);
- if ((pter[i].p32buf=(short*)malloc((chd.xlen*chd.ylen)<<9))==NULL)
- { SPM_errMes("メモリ不足です");fclose(fp);return; }
-
- if ((pter[i].patbuf=(char*)malloc((chd.xlen*chd.ylen)<<7))==NULL)
- { SPM_errMes("メモリ不足です");fclose(fp);return; }
- pter[i].header=NULL;
- pter[i].patx=chd.xlen; pter[i].paty=chd.ylen;
- pter[i].palnum=chd.col;
- if (pter[i].palnum==0)
- pter[i].palnum--;
- else
- pter[i].palnum=(pter[i].palnum & 32767)-256+PALNUM;
- }
-
- for (i=0;i<hd.palnum;i++)
- fread(PAL[i+PALNUM],32,1,fp);
-
- for (i=PATNUM;i<PATNUM+hd.patnum;i++)
- {
- lx=pter[i].patx; ly=pter[i].paty;
- /* 32K */
- if (pter[i].palnum==-1)
- {
- for (y=0;y<ly;y++)
- {
- for(x=0;x<lx;x++)
- {
- fread(tmpbuf,512,1,fp);
- for (j=0;j<16;j++)
- {
- _move( (&tmpbuf[j<<5]),
- (&pter[i].p32buf[(y*lx<<8)+(x<<4)+(j*lx<<4)]),32);
- }
- }
- }
- }
- else /* 16 */
- {
- for (y=0;y<ly;y++)
- {
- for(x=0;x<lx;x++)
- {
- fread(tmpbuf,128,1,fp);
- for (j=0;j<16;j++)
- {
- _move(&tmpbuf[j<<3],
- (&pter[i].patbuf[(y*lx<<7)+(x<<3)+(j*lx<<3)]),8);
- }
- }
- }
- SPM_expand(i,pter[i].patx*16,pter[i].paty*16,
- PAL[pter[i].palnum],pter[i].p32buf);
- PAL_USE[pter[i].palnum]++;
- }
- }
-
- PATNUM+=hd.patnum; PALNUM+=hd.palnum; SPRNUM+=hd.sprnum;
-
- fclose(fp);
- YGU_resetScrollBar(gwork,itm[29],(PATNUM+5)/6,4);
- YGU_setScrollBarPointer(gwork,itm[29],WINTOP);
- YGB_writeMode(gwork,PSET);
- SPM_showWindow(WINTOP*6);
- SPM_printNumber(WINTOP*6);
- free(tmpbuf);
- return;
- }
-
-
-
- /* ARTemis形式でセーブ */
- void SPM_savePAT()
- {
- P_HEAD header;
- char fn[13]; /* ファイルネーム */
- char name[41]; /* パターンの名前を一時的に格納するバッファ */
- int dotnum;
- int i,j,ret,pt=0;
-
-
- fn[0]=0;
- SPM_fileSelect("ARTemisセーブ",fn,"");
- if (fn[0]==0)
- return;
-
- YSC_makeFullPath(workfn,drv,path,fn);
-
- if ( (fp=fopen(workfn,"rb"))!=NULL)
- {
- if (SPM_sure(" @@ 上書きします @@ いいですか? ",0)==0)
- return;
- }
- fclose(fp);
- if ((fp=fopen(workfn,"wb"))==NULL)
- { SPM_errMes("ファイルエラー!"); return; }
-
-
-
- for (i=0;i<PATNUM;i++)
- {
- dotnum=pter[i].patx*pter[i].paty<<8;
- if (pter[i].header==NULL)
- {
- sprintf(name,"SPP-%d",i);
- strcpy(header.name,name);
- sprintf(name,"%d",i);
- strcpy(header.subname,name);
- header.xlen=pter[i].patx<<4;
- header.ylen=pter[i].paty<<4;
- header.bufx=(i%13)<<4;
- header.bufy=(i/13)<<4;
- header.patbufsize=dotnum<<1;
- header.res1=0; header.res2=1; header.res3=1; header.res4[0]=0;
- header.selected=0; header.nodisp=0;
- }
- else
- {
- _move(pter[i].header,&header,sizeof(P_HEAD));
- header.xlen=pter[i].patx<<4;
- header.ylen=pter[i].paty<<4;
- header.patbufsize=dotnum<<1;
- }
- if (fwrite(&header,sizeof(P_HEAD),1,fp)!=1)
- {SPM_errMes("ディスク容量が不足してませんか?");fclose(fp);return; }
- if (pter[i].palnum!=-1)
- {
- if (SPM_plus32K(i)!=0)
- return;
- }
- if (fwrite(pter[i].p32buf,2,dotnum,fp)!=dotnum)
- {SPM_errMes("ディスク容量が不足してませんか?");fclose(fp);return; }
- }
- fclose(fp);
- return;
- }
-
-
-
-
-
-
-
- /* 最適化メニュー */
- /* 指定範囲を16色に */
- void SPM_be16(int st,int en)
- {
- int i,j,ret,flag=0;
- short *patbuf; /* パターンデータ格納用 */
- char *pat;
- int dotnum; /* ドットの数 */
-
-
- for (i=st;i<en+1;i++)
- {
- dotnum=pter[i].patx*pter[i].paty*256;
- if (pter[i].palnum!=-1)
- continue;
-
- for (j=0;j<1024;j++)
- {
- if (PAL_USE[j]==0)
- {
- PAL_USE[j]++; flag=1;
- pter[i].palnum=j; PALNUM++;
- break;
- }
- }
-
- if (flag==0)
- { SPM_errMes("パレットの定義数が多すぎます");return;}
-
- patbuf=pter[i].p32buf;
- /* 16色に最適化する */
- ret=SOP_selPal(PAL[pter[i].palnum],patbuf,dotnum,OP_LEVEL*OP_LEVEL);
- if (ret!=0)
- { SPM_errMes("最適化中にメモリ不足が生じたようです。"); return; }
- ret=SOP_optimize(pter[i].patbuf,PAL[pter[i].palnum],patbuf,dotnum);
- if (ret!=0)
- { SPM_errMes("最適化中にメモリ不足が生じたようです。"); return; }
-
- }
-
- SPM_showWindow(WINTOP*6);
- SPM_printNumber(WINTOP*6);
-
- return;
- }
-
-
-
- /* 全部16色にする */
- void SPM_all16()
- {
- SPM_be16(0,PATNUM-1);
- return;
- }
-
-
-
-
- /* 範囲指定付き16色最適化 */
- void SPM_limit16()
- {
- int st,en;
-
- st=SPM_getScope();
- en=st & 65535;
- st=st>>16;
-
- SPM_be16(st,en);
- return;
- }
-
-
-
-
- /* 退避中のパレットによる最適化 */
- void SPM_pushed()
- {
- int i,j,ret,st,en;
- short *patbuf; /* パターンデータ格納用 */
- char *pat;
- int dotnum; /* ドットの数 */
-
- if (stkpal==-1)
- { SPM_errMes("パレットが退避先に有りません"); return; }
-
-
- st=SPM_getScope();
- en=st & 65535;
- st=st>>16;
-
- for (i=st;i<en+1;i++)
- {
- dotnum=pter[i].patx*pter[i].paty*256;
- if (pter[i].palnum!=-1)
- continue;
- if (pter[i].palnum==stkpal)
- continue;
-
- PAL_USE[stkpal]++;
- pter[i].palnum=stkpal;
- patbuf=pter[i].p32buf;
- /* 16色に最適化する */
- ret=SOP_optimize(pter[i].patbuf,PAL[stkpal],patbuf,dotnum);
- if (ret!=0)
- { SPM_errMes("最適化中にメモリ不足が生じたようです。"); return; }
-
- }
-
- SPM_showWindow(WINTOP*6);
- SPM_printNumber(WINTOP*6);
-
- return;
- }
-
-
-
-
- /* 32K色化 */
- void SPM_be32K(int st,int en)
- {
- int i;
-
- for (i=st;i<en+1;i++)
- {
- if (pter[i].p32buf==NULL)
- continue;
- if (pter[i].palnum==-1)
- continue;
-
- if ((--PAL_USE[pter[i].palnum]) == 0)
- PALNUM--;
- pter[i].palnum=-1;
- }
-
- SPM_showWindow(WINTOP*6);
- SPM_printNumber(WINTOP*6);
-
- return;
- }
-
-
- /* 全部32K色 */
- void SPM_all32K()
- {
- SPM_be32K(0,PATNUM-1);
- return;
- }
-
-
- /* 範囲指定付き32K色化 */
- void SPM_limit32K()
- {
- int st,en;
-
- st=SPM_getScope();
- en=st & 65535;
- st=st>>16;
-
- SPM_be32K(st,en);
- return;
- }
-
-
-
- /* 16色以下を全部最適化 */
- void SPM_under16()
- {
-
- short *patbuf;
- char *pat;
- int dotnum,flag;
- int colnum=0;
- int i,j,ref,ret,min,d,min_i,min_j;
- short *buf;
-
- for (i=0;i<PATNUM;i++)
- {
- /* 32K以外お断り */
- if (pter[i].palnum!=-1)
- continue;
-
- flag=0;
- colnum=0;
- patbuf=pter[i].p32buf;
- dotnum=pter[i].patx*pter[i].paty*256;
- /* バッファを確保 */
- if ( (buf=malloc(dotnum*2))==NULL)
- { SPM_errMes("メモリが足りません"); return; }
-
- /* バッファにコピー */
- _move(patbuf,buf,dotnum*2);
-
- /* 色番号順にソート */
- SOP_qsort(buf,0,dotnum-1);
-
- /* 色数のカウント*/
- ref=buf[0]; colnum++;
- for (j=1;j<dotnum;j++)
- {
- if (ref!=buf[j])
- { ref=buf[j];buf[colnum]=ref; colnum++; }
- }
- free(buf);
-
- /* 16色以下なら最適化 */
- if (colnum>16)
- continue;
-
- /* あいてるパレットを探す */
- for (j=0;j<1024;j++)
- {
- if (PAL_USE[j]==0)
- {
- PAL_USE[j]++; flag=1;
- pter[i].palnum=j; PALNUM++;
- break;
- }
- }
-
- if (flag==0)
- { SPM_errMes("パレットの定義数が多すぎます");return;}
-
- /* 16色に最適化する */
- ret=SOP_selPal(PAL[pter[i].palnum],patbuf,dotnum,OP_LEVEL*OP_LEVEL);
- if (ret!=0)
- { SPM_errMes("最適化中にメモリ不足が生じたようです。"); return; }
- ret=SOP_optimize(pter[i].patbuf,PAL[pter[i].palnum],patbuf,dotnum);
- if (ret!=0)
- { SPM_errMes("最適化中にメモリ不足が生じたようです。"); return; }
-
- }
-
- SPM_showWindow(WINTOP*6);
- SPM_printNumber(WINTOP*6);
-
- return;
- }
-
-
-
-
- /* 32K色データをメモリに持たない16色パターンに32Kデータを与える */
- int SPM_plus32K(int num)
- {
- SPM_expand(num,pter[num].patx*16,pter[num].paty*16,
- PAL[pter[num].palnum],pter[num].p32buf);
- return(0);
- }
-
-
-
-
- /* パレット番号の整理 */
- int SPM_arrangePALnumber()
- {
- int i,j,p,d;
-
-
- if (stkpal!=-1)
- {
- SPM_sure(" @@ @@ パレット退避用領域をクリアします ",2);
-
- if ( (--PAL_USE[stkpal])==0 )
- PALNUM--;
- stkpal=-1;
- }
-
- for (i=0;i<1024;i++)
- {
- d=0;
- if (PAL_USE[i]==0)
- {
- pal_lab:;
- d++;
- if (i+d>1023)
- break;
- if (PAL_USE[i+d]==0)
- goto pal_lab;
- for (j=i;j<1024-d;j++)
- {
- PAL_USE[j]=PAL_USE[j+d];
- _move(PAL[j+d],PAL[j],32);
- }
- for (j=1024-d;j<1024;j++)
- {
- PAL_USE[j]=0;
- _fill_char(PAL[j],32,0);
- }
- for (j=0;j<PATNUM;j++)
- {
- if (pter[j].palnum>=i+d)
- pter[j].palnum-=d;
- }
- }
- }
-
- return(0);
- }
-
-
-
-
- /* フリーメモリの表示 */
- void SPM_freeMem()
- {
- int k=1,m=1;
- char *dmy,*dmy2;
- char str[100];
-
- /* まずは、メガバイト単位から */
-
- if ((dmy=malloc(1024*1024))==NULL)
- { m=0; goto KB; }
- while(realloc(dmy,m*1024*1024)!=NULL)
- m++;
-
- /* 次にキロバイト単位 */
- KB:;
- if ((dmy2=(char*)malloc(1024))==NULL)
- { k=0; goto ED; }
- while(realloc(dmy2,k*1024)!=NULL)
- k++;
-
- ED:;
- free(dmy);
- free(dmy2);
-
- sprintf(str," @@ @@FREE MEMORY...%dKbytes",(m-1)*1024+k-1);
- SPM_sure(str,2);
- return;
- }
-
-
-
-
- /* 範囲入力(始まり*65536+終わりを返す)、PATNUM=0で9999 */
- int SPM_getScope()
- {
- ITEM *itms[26],*act;
- int i,j,x,y;
- int flag=0; /* ループ抜け出し用 */
- int wb; /* WINTOP退避用 */
- int ret=0;
-
-
- if (PATNUM==0)
- return(9999);
-
- SPM_sure("@@ @@始まるパターンは?",2);
-
-
- /* ダミー */
- itms[0]=YGU_addButton(NULL,511,511,1,1);
-
- /* 各パターン表示ウィンドウ itms 1-24 */
- for (j=0;j<4;j++)
- {
- for (i=0;i<6;i++)
- {
- x = i * sprWinStep_x + sprWin_x;
- y = j * sprWinStep_y + sprWin_y;
- YGU_addButton(itms[0],x+6,y+6,64,64);
- }
- }
-
-
- /* スクロールバー (itms 25)*/
- YGU_addLongitudinalbar(gwork,itms[0],0,20,12,458,(PATNUM+5)/6,4);
- YGU_setScrollBarPointer(gwork,itms[25],WINTOP);
- YGB_writeMode(gwork,PSET);
- wb=WINTOP;
-
- for (i=0;i<25;i++)
- itms[i+1]=YGU_nextItem(itms[i]);
-
-
- while(flag<2)
- {
- act=YGU_allItemsAction(gwork,itms[0]);
- i=YGU_itemSerialNumber(itms[0],act);
- switch(i)
- {
- default: break;
- case 2..25:
- {
- if (WINTOP*6+i-2 >= PATNUM)
- break;
- ret+=WINTOP*6+i-2; flag++;
- if (flag==1)
- {
- ret=ret<<16;
- SPM_sure(" @@ @@では、終わるパターンは?",2);
- }
- break;
- }
- case 26:
- {
- j=YGU_getScrollBarPointer(itms[25]);
- if (_abs((j-WINTOP))<=3)
- SPM_scrollShowWindow(j-WINTOP);
- else
- {
- WINTOP=j;
- SPM_showWindow(WINTOP*6);
- }
- }
- }
- }
-
- YGU_deleteAll(itms[0]);
- WINTOP=wb;
- YGU_setScrollBarPointer(gwork,itm[29],WINTOP);
- SPM_showWindow(WINTOP*6);
- return(ret);
- }
-
-
-
-
- /* 一つのパターンを指定させる */
- int SPM_getOne()
- {
- ITEM *itms[26],*act;
- int i,j,x,y;
- int flag=0; /* ループ抜け出し用 */
- int wb; /* WINTOP退避用 */
- int ret;
-
-
- if (PATNUM==0)
- return(9999);
-
- SPM_sure("@@ @@どのパターンですか?",2);
-
-
- /* ダミー */
- itms[0]=YGU_addButton(NULL,511,511,1,1);
-
- /* 各パターン表示ウィンドウ itms 1-24 */
- for (j=0;j<4;j++)
- {
- for (i=0;i<6;i++)
- {
- x = i * sprWinStep_x + sprWin_x;
- y = j * sprWinStep_y + sprWin_y;
- YGU_addButton(itms[0],x+6,y+6,64,64);
- }
- }
-
-
- /* スクロールバー (itms 25)*/
- YGU_addLongitudinalbar(gwork,itms[0],0,20,12,458,(PATNUM+5)/6,4);
- YGU_setScrollBarPointer(gwork,itms[25],WINTOP);
- YGB_writeMode(gwork,PSET);
- wb=WINTOP;
-
- for (i=0;i<25;i++)
- itms[i+1]=YGU_nextItem(itms[i]);
-
-
- while(flag==0)
- {
- act=YGU_allItemsAction(gwork,itms[0]);
- i=YGU_itemSerialNumber(itms[0],act);
- switch(i)
- {
- default: break;
- case 2..25:
- {
- ret=WINTOP*6+i-2; flag++;
- break;
- }
- case 26:
- {
- j=YGU_getScrollBarPointer(itms[25]);
- if (_abs((j-WINTOP))<=3)
- SPM_scrollShowWindow(j-WINTOP);
- else
- {
- WINTOP=j;
- SPM_showWindow(WINTOP*6);
- }
- }
- }
- }
-
- YGU_deleteAll(itms[0]);
- WINTOP=wb;
- YGU_setScrollBarPointer(gwork,itm[29],WINTOP);
- SPM_showWindow(WINTOP*6);
- return(ret);
- }
-
-
-
-
-
-
-
-
- /* ウェイト */
- void SPM_wait(int count)
- {
- int a,b;
- b=MOS_getTime();
- while(1)
- {
- a=MOS_getTime();
- if ( a-b > count )
- break;
- }
- return;
- }
-
-
- /* リドロー */
- void SPM_redraw()
- {
- int x,y,i,j,r;
- char para[64];
-
- MOS_disp(0);
- YGB_writeMode(gwork,PSET);
-
- YGB_color(gwork,0);
-
- /* どれにしようかな?(^^;) */
- dice:;
- r=rand()&3;
-
- switch (r)
- {
- case 0:
- /* HEwinの反対っぽい消去 */
- for (i=0;i<16;i++)
- {
- for (j=0;j<32;j++)
- {
- YGB_line(gwork,(j<<4)+i,0,(j<<4)+i,479);
- if (j<30)
- YGB_line(gwork,0,(j<<4)+i,511,(j<<4)+i);
- }
- }
- break;
-
- case 1:
- /* ブラインド? */
- for (i=15;i>=0;i--)
- {
- for (j=0;j<30;j++)
- YGB_line(gwork,0,(j<<4)+i,511,(j<<4)+i);
- SPM_wait(1);
- }
- break;
-
- case 2:
- /* 上スクロール */
- for (i=1;i<40;i++)
- {
- EGB_displayStart(gwork,1,0,i*12);
- YGB_boxFul(gwork,0,(i-1)*12,511,(i-1)*12+11);
- }
- EGB_displayStart(gwork,1,0,0);
- break;
-
- case 3:
- /* ソーサリアン? */
- EGB_maskBit(gwork,0x7c007c00);
- YGB_boxFul(gwork,0,0,511,479);
- SPM_wait(10);
-
- EGB_maskBit(gwork,0x001f001f);
- YGB_boxFul(gwork,0,0,511,479);
- SPM_wait(10);
-
- EGB_maskBit(gwork,0x03e003e0);
- YGB_boxFul(gwork,0,0,511,479);
- SPM_wait(10);
-
- EGB_maskBit(gwork,0xffffffff);
- break;
- }
-
- /* 背景色 */
- YGB_color(gwork,C_BACK);
- YGB_boxFul(gwork,0,0,511,479);
-
- /* 画面上方の溝(?) */
- YGB_color(gwork,C_BACK);
- YGB_boxFul(gwork,259,-2,494,18);
-
- /* EXITボタン (itm[0])*/
- SGB_gradProButton(gwork,493,0,511,18,_C(24,24,24),_C(8,8,8),0);
-
-
- /* タイトル (itm[1])*/
- SGB_gradProButton(gwork,0,0,112,18,_C(12,12,12),_C(0,0,0),0);
- YGB_color(gwork,_C(25,25,25));
- YGB_fontSize(gwork,6,12);
- YGB_print(gwork,15,14,"SPP Ver1.00");
- YGB_color(gwork,_C(27,27,27));
- YGB_print(gwork,16,14,"SPP Ver1.00");
-
- /* ファイルメニュー (itm[2])*/
- SGB_proButton(gwork,113,0,192,18, _C(0,0,0));
- YGB_color(gwork,_C(27,27,27));
- YGB_print(gwork,128,14,"ファイル");
- YGB_color(gwork,_C(12,12,12));
- YGB_fontSize(gwork,3,6);
- YGB_print(gwork,179,13,"▼");
-
- /* 最適化メニュー (itm[3])*/
- SGB_proButton(gwork,193,0,260,18, _C(0,0,0));
- YGB_color(gwork,_C(27,27,27));
- YGB_fontSize(gwork,6,12);
- YGB_print(gwork,208,14,"最適化");
- YGB_color(gwork,_C(12,12,12));
- YGB_fontSize(gwork,3,6);
- YGB_print(gwork,247,13,"▼");
-
-
- /* 現在のパターン番号等表示 */
- YGB_fontSize(gwork,6,12);
- SGB_holButton(gwork,print_x,print_y,print_x+191,print_y+15,_C(0,0,0));
- YGB_color(gwork,_C(27,27,27));
- YGB_print(gwork,print_x+2,print_y+13,"now:");
- SPM_printNumber(0);
-
-
- /* 各キャラデータの表示ウィンドウ(itm[4]-itm[27]) */
- x = sprWin_x;
- y = sprWin_y;
- /* パターン表示 */
- SGB_proButton(gwork,x ,y, x+75,y+75, _C(22,22,22));
- SGB_holButton(gwork,x+6,y+6,x+69,y+69, _C(0,0,0));
- /* パレットの表示 */
- SGB_holButton(gwork,x ,y+78,x+74,y+98, _C(0,0,0));
-
- YGB_getPattern(gwork,frameBuf,x,y,x+75,y+98);
-
- /* コピーする(一回余分があるけどまあいいね(^^;)) */
- for (j=0;j<4;j++)
- {
- for (i=0;i<6;i++)
- {
- x = i * sprWinStep_x + sprWin_x;
- y = j * sprWinStep_y + sprWin_y;
- YGB_putPattern(gwork,frameBuf,x,y,x+75,y+98);
-
- }
- }
-
- YGU_setScrollBarPointer(gwork,itm[29],WINTOP);
- SPM_showWindow(WINTOP*6);
- SPM_printNumber(WINTOP*6);
- MOS_rdpos(&i,&x,&y);
- MOS_setpos(x,y);
- MOS_disp(1);
-
- return;
- }
-
-
-
-
-
-
-
- /* 透過色の指定 */
- void SPM_setThru()
- {
-
- return;
- }
-
-
-